<%-- 
    Document   : edit
    Created on : 02.05.2009, 19:38:08
    Author     : Vladimir
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="ru.prjpeople.model.Person"%>
<%@page import="ru.prjpeople.model.Position"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Редактирование персоны</title>
    </head>
    <body>
        <%String msg = (String) request.getAttribute("errorMessage");%>
        <%Person person = (Person)request.getAttribute("person");%>
        <%if(person != null) {%>
            <form method="post" action="saveperson">
                <table>
                    <caption align="left">Редактирование человека</caption>
                    <tr>
                        <td>Фамилия:</td>
                        <td>
                            <input type="text" name="lastName" value="${person.lastName}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>Имя:</td>
                        <td>
                            <input type="text" name="name" value="${person.name}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>Отчество:</td>
                        <td>
                            <input type="text" name="patronymic" value="${person.patronymic}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>Должность:</td>
                        <td>
                            <select name="position">
                                <option value="0">
                                    --выберите должность
                                </option>
                                <%for(Position p: Position.values()) {%>
                                    <option value="<%=p.name() %>" 
                                    <%if(p == person.getPosition()) {%>
                                        selected
                                    <%}%>
                                    >
                                    <%=p.getTitle()%>
                                </option>
                                <%}%>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>ИД:</td>
                        <td>
                            <input type="text" value="<%=person.getKey()%>" disabled/>
                            <input type="hidden" name="personID" value="<%=person.getKey()%>"/>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <input type="submit" value="сохранить"/>
                        </td>
                    </tr>
                </table>
            </form>
            <% if(msg != null) {%>
                <p>
                    <%=msg%>
                </p>
            <%}%>
        <%}%>
    </body>
</html>
